#include "StdAfx.h"
#include "DrawDynamicBorderTest.h"


CDrawDynamicBorderTest::CDrawDynamicBorderTest(void)
{
    laplace = 0;
    //colorlaplace = 0;
    planes[0] = 0;
	planes[1] = 0;
	planes[2] = 0;
}


CDrawDynamicBorderTest::~CDrawDynamicBorderTest(void)
{
}
BEGIN_MESSAGE_MAP(CDrawDynamicBorderTest, CDrawOpenCV)
	ON_WM_PAINT()
END_MESSAGE_MAP()



void CDrawDynamicBorderTest::DealwithFrame()
{
	// TODO: Add your command handler code here
	if(m_pFrame == NULL)
	{			
		return ;
	}
	if(m_pShow == NULL)
	{
        for(int i = 0; i < 3; i++ )
            planes[i] = cvCreateImage( cvSize(m_pFrame->width,m_pFrame->height), 8, 1 );
        laplace = cvCreateImage( cvSize(m_pFrame->width,m_pFrame->height), IPL_DEPTH_16S, 1 );
        m_pShow = cvCreateImage( cvSize(m_pFrame->width,m_pFrame->height), 8, 3 );

	}
    cvCvtPixToPlane( m_pFrame, planes[0], planes[1], planes[2], 0 );
    for(int i = 0; i < 3; i++ )
    {
        cvLaplace( planes[i], laplace, 3 );
        cvConvertScaleAbs( laplace, planes[i], 1, 0 );
    }
    cvCvtPlaneToPix( planes[0], planes[1], planes[2], 0, m_pShow );
    m_pShow->origin = m_pFrame->origin;

    //cvShowImage("Laplacian", m_pShow );



}
